void (*PutByte)(unsigned char bank, unsigned short addr, unsigned char x, Boolean mode);
unsigned char (*GetByte)(unsigned char bank, unsigned short addr, Boolean mode);
} prozState;
*GetByte and *PutByte are functions to read and write to the GS memory. The mode flag specifies whether these calls respect special memory areas (true) or not (false). Special memory areas are LC card, bank switched memory, shadowed memory, softswitches, video memory, CX00 IO memory, etc.
Note that there's no P register. Modify the status flags directly instead (0 = false, else true). Also, the C register holds just the A register (high byte 0) when m or e = 1. The high byte is then saved in the high byte of B. B is not valid when m = 0.
writing stubs
Stubs are small subroutines that build the interface between 65816 and PPC code. The actual call is done by the COP command as following example clarifies:
COP $F0 ; $F0 identifies PPC program in GS memory
DB $00 ; zero, forces BRK when running on real 65816
DB $01 ; any byte non zero, identifier to prevent accidents
DB $A4 ; above byte xor'ed with $A5, another security issue
DL PPCCodeAdr ; pointer (65816 little endian) to PPC program in GS memory
and
COP $F1 ; $F1 identifies PPC program in Mac memory
DB $00
DB $01
DB $A4
DL PPCCodeAdr ; pointer (65816 little endian) to PPC program in Mac memory
Example stub:
mult clc
xce
rep #30
ldx A
ldy B
cop #F0
db 00,01,A4
dl mult_PPC
sta C
sec
xce
rts
A ds 2
B ds 2
C ds 2
writing PPC programs
Write the code with any PPC assembler and include it directly into your 65816 assembler.